function [ finalArrayPlate,  finalArrPlateColor,  finalArrayCharacter, finalArrayPosition, finalArrayCharSegment ] = StepRecognizeCharacter( arrImaResult, arrayImageResultColor, arrayImagResPosition, FOLDER_RESULT, IS_DEBUG, filename)
%STEPRECOGNIZECHARACTER Summary of this function goes here
%   Detailed explanation goes here
count = 1;
finalArrayCharacter = {};
finalArrayPlate = {};
finalArrPlateColor = {};
finalArrayPosition = {};
finalArrayCharSegment ={};

recognizeFolder = strcat(FOLDER_RESULT,'\InStepSegment');
if exist(recognizeFolder,'dir') ==0
    mkdir(recognizeFolder);
end

segmentTrueFolder = strcat(FOLDER_RESULT,'\InStepSegment\SegmentTrue');
if exist(segmentTrueFolder,'dir') ==0
    mkdir(segmentTrueFolder);
end

segmentFailFolder = strcat(FOLDER_RESULT,'\InStepSegment\SegmentFail');
if exist(segmentFailFolder,'dir') ==0
    mkdir(segmentFailFolder);
end


for i=1:length(arrImaResult)
    img = arrayImageResultColor{i};
    z = size(img,3);
    if z==3
        img = rgb2gray(img);
    end
    if (IS_DEBUG)
        imwrite(arrayImageResultColor{i},strcat(recognizeFolder,'\', ...
            filename,'--',num2str(i),'--','.JPG'),'JPG');
    end
    for mode=1:4
        minCharacter = 6;
        maxCharacter = 9;
        a = characterSegment.characterSegmentation(img,0,FOLDER_RESULT,filename, mode);
        if (length(a)>= minCharacter && length(a)<= maxCharacter)
            if (IS_DEBUG)
                imwrite(arrayImageResultColor{i},strcat(segmentTrueFolder,'\', ...
                    filename,'--',num2str(i),'--','.JPG'),'JPG');
            end
            re = '1';
            finalArrayPlate{count} = arrImaResult{i};
            finalArrayCharacter{count} = re;
            finalArrPlateColor{count} = arrayImageResultColor{i};
            finalArrayPosition{count} = arrayImagResPosition{i};
            finalArrayCharSegment{count} = a;
            count = count + 1;
            break;
        else
            if (mode == 4)
                if (IS_DEBUG)
                    imwrite(arrayImageResultColor{i},strcat(segmentFailFolder,'\', ...
                        filename,'--',num2str(i),'--','.JPG'),'JPG');
                end
            end
        end
    end
    
end

end
